import java.util.Comparator;
import java.util.Arrays;

public class ao1demo1 {
    public static void main(String[] args) {
        GirlFriend gf1 = new GirlFriend("张三", 18, "1.65m");
        GirlFriend gf2 = new GirlFriend("李四", 19, "1.68m");
        GirlFriend gf3 = new GirlFriend("王五", 29, "1.70m");

        GirlFriend[] arr = {gf1, gf2, gf3};

        Arrays.sort(arr, new Comparator<GirlFriend>() {
            @Override
            public int compare(GirlFriend o1, GirlFriend o2) {

                double temp = o1.getAge() - o2.getAge();
                temp = temp == 0 ? o1.getTall().compareTo(o2.getTall()) : temp;
                temp = temp == 0 ? o1.getNeme().compareTo(o2.getNeme()) : temp;

                if (temp > 0) {
                    return 1;
                } else if (temp < 0) {
                    return -1;
                } else {
                    return 0;
                }

            }
        });
        System.out.println(Arrays.toString(arr));
    }
}

class GirlFriend {
    private String neme;
    private int age;
    private String tall;

    public GirlFriend() {
    }

    public GirlFriend(String neme, int age, String tall) {
        this.neme = neme;
        this.age = age;
        this.tall = tall;
    }

    public String getNeme() {
        return neme;
    }

    public void setNeme(String neme) {
        this.neme = neme;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getTall() {
        return tall;
    }

    public void setTall(String tall) {
        this.tall = tall;
    }
}